package com.jackeysun.app_widget

import android.os.Handler
import android.os.Looper
import java.util.regex.Pattern

/**
 *   Created by sunxunchao on 2021/12/23.
 */
class Test {


}

fun main() {
    val pattern = "&nbsp;([1-9]\\d*\\.?\\d*)\\s"
    val changeFont =
        DataSource.html.replace(Regex(pattern)) {
            "<font style=\"color: rgba(255,255,255,1);background: rgba(0,0,0,1);display: inline-block;width: 24px;height: 24px;font-size: 14px;border-radius: 50%;line-height: 24px;\"  >&nbsp;${it.value.getDigital()} </font>"
        }

    println(changeFont)
}


/**
 * 获取字符串中的数字
 */
fun String.getDigital(): String {
    val digital = StringBuffer()
    val matcher = Pattern.compile("\\d").matcher(this)
    while (matcher.find()) {
        digital.append(matcher.group())
    }
    return digital.toString()
}